﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

/// <summary>
/// Summary description for VacancyMethord
/// </summary>
public class VacancyMethord
{
    SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);

    public DataTable VacancySearch(string _title)
    {
        DataTable tb = null;
        try
        {
            if (sqlconn.State == ConnectionState.Closed)
            {
                sqlconn.Open();
            }
            SqlCommand sqlcmm = new SqlCommand("EXECUTE SearchVacancy @Title", sqlconn);            
            sqlcmm.Parameters.AddWithValue("@Title", _title);
            SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmm);
            DataSet ds = new DataSet();
            sqlda.Fill(ds);
            tb = ds.Tables[0];
            
        }
        catch (Exception)
        {

            throw;
        }
        return tb;
    }
    public DataTable ViewAllVacancy() { 
    DataTable tb = new DataTable();
    try
    {
        SqlCommand comm = new SqlCommand("SELECT * FROM vw_AllVacancy", sqlconn);
        if (sqlconn.State == ConnectionState.Closed)
        {
            sqlconn.Open();
        }
        SqlDataAdapter da = new SqlDataAdapter(comm);
        DataSet ds = new DataSet();
        da.Fill(ds);
        tb = ds.Tables[0];
        
    }
    catch (Exception ex)
    {

        Console.Write(ex.Message);
    }
    finally {
        sqlconn.Close();
    }

    return tb;
    }

   
}